﻿CREATE VIEW dbo.VIEWS_SEARCH_VAT_INVOICE
AS
SELECT        dbo.CONTRACT.NUMBER AS CONTRACT_NUM, dbo.NSI_ORGANIZATION.SHORT_NAME AS NSI_ORGANIZATION_SHORT_NAME, 
                         dbo.NSI_TYPE_OF_ACTIVITY.NAME AS NSI_TYPE_OF_ACTIVITY_NAME, dbo.VAT_INVOICE.PID, dbo.VAT_INVOICE.ID, dbo.VAT_INVOICE.NUMBER, 
                         dbo.VAT_INVOICE.DATE, dbo.VAT_INVOICE.SUM_RUB, dbo.VAT_INVOICE.NSI_ORGANIZATION_ID
FROM            dbo.NSI_ORGANIZATION RIGHT OUTER JOIN
                         dbo.VAT_INVOICE ON dbo.NSI_ORGANIZATION.ID = dbo.VAT_INVOICE.NSI_ORGANIZATION_ID LEFT OUTER JOIN
                         dbo.CONTRACT ON dbo.VAT_INVOICE.PID = dbo.CONTRACT.PID LEFT OUTER JOIN
                         dbo.NSI_TYPE_OF_ACTIVITY ON dbo.CONTRACT.NSI_TYPE_OF_ACTIVITY_ID = dbo.NSI_TYPE_OF_ACTIVITY.ID